/**
 * 撤销重复工具
 */
	var ToolRedoUndo = function() {
		/**
		 * 重置
		 */
		this.reset = function() {
			this.redo_stack.clear();
			this.undo_stack.clear();
		}

		/**
		 * 撤回
		 * @param {Object} obj 操作对象
		 * @param {Function} print 打印方法
		 * @param {Object} win 打印成功回调
		 */
		this.redo = function(obj,print, win) {
			this.undo_stack.push(this.redo_stack.pop());
			print();
			win(obj);
		}

		/**
		 * 撤销
		 * @param {Object} obj 操作对象
		 * @param {Function} print 打印方法
		 * @param {Object} win 打印成功回调
		 */
		this.undo = function(obj,print, win) {
			this.redo_stack.push(this.undo_stack.pop());
			print();
			win(obj);
		}

		this.redo_stack = {
			push: function(obj) {
				this.redo_stack || (this.redo_stack = []);
				return this.redo_stack.push(obj);
			},
			pop: function() {
				if (this.redo_stack) {
					if (this.redo_stack.length > 0) {
						return this.redo_stack.pop();
					} else {
						return false;
					}
				} else {
					return false;
				}
			},
			get_stack: function() {
				return this.redo_stack || [];
			},
			clear: function() {
				this.redo_stack = void 0;
			}
		};
		
		this.undo_stack = {
			push: function(obj) {
				this.undo_stack || (this.undo_stack = []);
				return this.undo_stack.push(obj);
			},
			pop: function() {
				if (this.undo_stack) {
					if (this.undo_stack.length > 0) {
						return this.undo_stack.pop();
					} else {
						return false;
					}
				} else {
					return false;
				}
			},
			get_stack: function() {
				return this.undo_stack || [];
			},
			clear: function() {
				this.undo_stack = void 0;
			}
		}


	};

module.exports = ToolRedoUndo;